package com.bike.bikeserver.controller.frontend;

import com.bike.bikeserver.common.annotation.OperationLog;
import com.bike.bikeserver.common.core.domain.CommonResult;
import com.bike.bikeserver.domain.vo.BikeRequestVo;
import com.bike.bikeserver.service.IBikeRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author ZZX
 * @Date 2023/7/9 22:02
 */
@RestController
@RequestMapping("front/bikeRequest")
public class BikeRequestController
{
    @Autowired
    IBikeRequestService bikeRequestService;

    /**
     * 发送请求并保存
     * 主要是针对单车淤积和乱停乱放两种请求
     *
     * @param bikeRequestVo
     * @return
     */
    @OperationLog(value = "发送乱放会淤积请求并保存:bike_request")
    @PostMapping("sendRequest")
    public CommonResult sendParkingRequest(@RequestBody BikeRequestVo bikeRequestVo)
    {
        return bikeRequestService.sendRequest(bikeRequestVo);
    }

    /**
     * 发送请求并保存
     * 主要是针对单车调度这种请求
     *
     * @param bikeRequestVo
     * @return
     */
    @OperationLog(value = "发送调度请求并保存:bike_request")
    @PostMapping("applyDispatch")
    public CommonResult applyDispatch(@RequestBody BikeRequestVo bikeRequestVo)
    {
        return bikeRequestService.applyDispatchRequest(bikeRequestVo);
    }


    /**
     * 根据用户名获得最新请求进度
     *
     * @param nickName
     * @return
     */
    @OperationLog(value = "根据用户名获得最新请求进度:bike_request")
    @GetMapping("getRequestListByNickName")
    public CommonResult getRequestListByNickName(@RequestParam("nickName") String nickName)
    {
        return bikeRequestService.getRequestListByNickName(nickName);
    }

    /**
     * 根据用户名获取请求列表
     *
     * @param nickName
     * @return
     */
    @OperationLog(value = "根据用户名获取请求列表:bike_request")
    @GetMapping("getRequestsByNickName")
    public CommonResult getRequestsByNickName(@RequestParam("nickName") String nickName)
    {
        return bikeRequestService.getRequestsByNickName(nickName);
    }
}